package com.atguigu.srb.core.controller.admin;


import com.atguigu.common.result.R;
import com.atguigu.srb.core.pojo.entity.BorrowInfo;
import com.atguigu.srb.core.pojo.vo.BorrowInfoApprovalVO;
import com.atguigu.srb.core.service.BorrowInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 借款信息表 前端控制器
 * </p>
 *
 * @author lupengning
 * @since 2021-05-27
 */

/**
 * @author lupengning
 * @version 1.0
 * @description:
 * @date 2021/6/15 19:33
 */
@Slf4j
@RestController
@Api(tags = "借款人信息管理")
@RequestMapping("/admin/core/borrowerInfo")
public class AdminBorrowInfoController {

  @Resource
  private BorrowInfoService borrowInfoService;

  @ApiOperation("审批借款信息")
  @PostMapping("/approval")
  public R approval(@RequestBody BorrowInfoApprovalVO borrowInfoApprovalVO) {

    borrowInfoService.approval(borrowInfoApprovalVO);
    return R.ok().message("审批完成");
  }

  @ApiOperation("借款信息列表")
  @GetMapping("/list")
  public R list() {
    List<BorrowInfo> borrowInfos = borrowInfoService.selectList();
    return R.ok().data("list", borrowInfos);
  }

  @ApiOperation("获取借款信息详情")
  @GetMapping("/show/{id}")
  public R showDetail(@ApiParam(value = "借款人Id", required = true) @PathVariable Long id) {

    Map<String,Object> borrowInfoDetail = borrowInfoService.getBorrowInfoDetail(id);
    return R.ok().data("borrowInfoDetail", borrowInfoDetail);
  }

}

